package com.zlm.user.emp.controller;

import com.zlm.common.base.BaseController;
import com.zlm.common.dto.JsonResultDto;
import com.zlm.common.entity.ProvinceDO;
import com.zlm.common.util.DateTimeUtils;
import com.zlm.user.emp.service.BasAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * 城市controller-对内服务
 * @Author: duyufu
 * @Date: 2019/4/29 9:40
 */
@RestController
@RequestMapping(value = "/area")
public class BasAreaController extends BaseController {

    @Autowired
    private BasAreaService basAreaService;

    @GetMapping("/queryAllCity")
    public JsonResultDto queryAllCity(){
        try {
            Long startTime = DateTimeUtils.getCurrentTimestamp().getTime();
            List<ProvinceDO> areaMenu= basAreaService.queryAllCity();
            Long endstart = DateTimeUtils.getCurrentTimestamp().getTime();
            long differMinuteNumber = DateTimeUtils.getDifferMinuteNumber(endstart, startTime);
            System.out.println("查询时间:"+ differMinuteNumber);
            return success(areaMenu);
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    @GetMapping("/queryPrefectureLevelCity")
    public JsonResultDto queryPrefectureLevelCity(){
        try {
            List<Map<String,Object>> areaMenu= basAreaService.queryPrefectureLevelCity();
            return success(areaMenu);
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }





}
